﻿@model IEnumerable<Enter.Mvc.Mall.Model.Product.ProductModel>
@{
    ViewBag.Title = "Search_product";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section Styles
{
    <link rel="stylesheet" href="/Content/themes/default/list.css" />
    <link rel="stylesheet" href="/Content/themes/default/list_cat.css" />
}
@section Scripts
{
    <script type="text/javascript">
        function menuFix() {
            if (!(document.getElementById("mallCate"))) { return; }
            var navEls = document.getElementById("mallCate");

            navEls.onmouseover = function () {
                this.className += (this.className.length > 0 ? " " : "") + "hover";
            }
            navEls.onMouseDown = function () {
                this.className += (this.className.length > 0 ? " " : "") + "hover";
            }
            navEls.onMouseUp = function () {
                this.className += (this.className.length > 0 ? " " : "") + "hover";
            }
            navEls.onmouseout = function () {
                this.className = this.className.replace(new RegExp("( ?|^)hover\\b"), "");
            }
        }

        if (window.addEventListener) {
            window.addEventListener("load", menuFix, false);
        } else {
            window.attachEvent("onload", menuFix);
        }
        $(function () {
            $("#J_FsdgRecommendProp .more").click(function () {
                if ($(this).attr("class") == "more close hidden" || $(this).attr("class") == "more hidden close") {
                    $(this).removeClass("close").addClass("open").html("<b class='icon'></b>收起");
                } else {
                    $(this).removeClass("open").addClass("close").html("<b class='icon'></b>更多");
                }
                $(this).parent().toggleClass("j_colPropClose");

            })
            $("#J_ColPropToggler a.close").click(function () {
                if ($(this).attr("class") == "close") {
                    $(this).toggleClass("open").html("<b class='icon grayUp'></b>精简选项");
                } else {
                    $(this).toggleClass("close").html("<b class='icon grayDown'></b>更多选项");

                }
                $("#J_ColMoreProp").toggle();
            })
            $(document).click(function (e) {
                hidetype(e);
            })
            $("#J_FilterCats").click(function () {
                $(this).next().find("ul").toggle();
            })
            $("div.search-menu ul li").click(function () {
                $(this).parent().parent().prev().find("span").text($(this).find("a").text());
                $(this).parent().hide();
            })
            $("#filterOrder").mouseover(function () {
                $(this).find("ul").show();
            })
            $("#filterOrder").mouseout(function () {
                $(this).find("ul").hide();
            })
            $("#filterLocation").mouseover(function () {
                $(this).find("div.item-list").show();
            })
            $("#filterLocation").mouseout(function () {
                $(this).find("div.item-list").hide();
            })

            $("#J_FilterPrice input").focus(function () {
                $("p.sub-menu").show();
            })
            $("#J_FilterPrice input").focusout(function () {
                $("p.sub-menu").hide();
            })

        })
        function hidetype(e) {
            var evt = e ? e : (window.event ? window.event : null); //此方法为了在firefox中的兼容
            var node = evt.srcElement ? evt.srcElement : evt.target; //evt.target在火狐上才能识别用的
            if (node == $("#J_FilterCats")[0]) return;

            if ($(node).parents('.search-menu').length == 0) {
                $("div.search-menu ul").hide();
            }
        }
    </script>
}
<div class="main pageWidth">
    <!--所有分类开始-->
    @{Html.RenderAction("AllProductCate", "Category");}
    <!--所有分类结束-->
    <!--侧边栏开始-->
    <div class=" mt">
        <div class="side" id="J_Side">
            <div class="sidebar-panel">
                @{Html.RenderAction("CategoryTree", "Category");}
            </div>
        </div>
        <div class="main-wrap">
            @{Html.RenderAction("HotProductsRank");}
            <div class="navigation mb10 clearfix" id="J_ColPropNavigation" _title="智能类目导航区">
                <div class="fsdgHomeAtt-hd clearself">
                    <h2 class="fsdgHomeAtt-title">
                        <a href="#;">秋水伊人</a> > <a href="#;">品牌女装</a> > <span>t恤</span></h2>
                    <p class="fsdgHomeAtt-count">
                        相关商品<em>@ViewData["totalPages"]</em>件</p>
                </div>
                @{Html.RenderAction("catePropList");}
            </div>
            <!--商品列表开始-->
            <div class="list item-view">
                <div class="filter" id="J_Filter">
                    <div class="search-filter">
                        <form id="filterForm" action="/Product/search_product">
                        <div class="filter-toolbar">
                            @{Html.RenderAction("searchbar", "Category");}
                            @{
                                Enter.Common.RequestHelper request = new Enter.Common.RequestHelper(Request.QueryString);
                                request.Remove("currentIndex");
                                 
                               
                           
                                <div id="filterLocation" class="location hoverMenu">
                                    <span class="select-item"><b>江浙沪 </b></span>
                                    <div class="item-list">
                                        <ul class="loc1">
                                            <li><a href="">所有地区</a></li>
                                        </ul>
                                        <ul class="loc2 split">
                                            <li class="checked"><a href="">江浙沪</a></li>
                                            <li><a href="">珠三角</a></li>
                                            <li><a href="">港澳台</a></li>
                                            <li><a href="">海外</a></li>
                                            <li><a href="">北京</a></li>
                                            <li><a href="">上海</a></li>
                                            <li><a href="">广州</a></li>
                                            <li><a href="">深圳</a></li>
                                        </ul>
                                        <ul class="loc3">
                                            <li><a href="">杭州</a></li>
                                            <li><a href="">温州</a></li>
                                            <li><a href="">宁波</a></li>
                                            <li><a href="">南京</a></li>
                                        </ul>
                                        <ul class="loc4 split">
                                            <li><a href="">安徽</a></li>
                                            <li><a href="">福建</a></li>
                                            <li><a href="">甘肃</a></li>
                                            <li><a href="">广东</a></li>
                                            <li><a href="">广西</a></li>
                                            <li><a href="">贵州</a></li>
                                            <li><a href="">海南</a></li>
                                            <li><a href="">河北</a></li>
                                            <li><a href="">河南</a></li>
                                        </ul>
                                    </div>
                                </div>
                                <div id="filterOrder" class="order hoverMenu  by-default ">
                                    <span class="select-item"><b class="icon"></b>默认排序</span>
                                    <ul class="order-options item-list" id="J_OrderByList">
                                        <li class="by-price-asc"><a href="search_product?@request.SetAndGetString("sort", "p")">
                                            <b class="icon"></b>价格从低到高</a> </li>
                                        <li class="by-price-desc"><a href="search_product?@request.SetAndGetString("sort", "pd")">
                                            <b class="icon"></b>价格从高到低</a> </li>
                                        <li class="by-sale-desc"><a href="search_product?@request.SetAndGetString("sort", "td")">
                                            <b class="icon"></b>总销量从高到低</a> </li>
                                        <li class="by-sale-desc"><a href="search_product?@request.SetAndGetString("sort", "d")">
                                            <b class="icon"></b>月销量从高到低</a> </li>
                                        <li class="by-top-time"><a href="search_product?@request.SetAndGetString("sort", "pt")">
                                            <b class="icon"></b>按发布时间排序</a> </li>
                                        <li class="by-default"><a href="search_product?@request.SetAndGetString("sort", "st")">
                                            <b class="icon"></b>恢复默认排序</a> </li>
                                    </ul>
                                </div>
                                <ul class="otherOrder">
                                    <a href="search_product?@request.SetAndGetString("sort", "d")"
                                        title="按月销量从高到低">销量<b class="descIcon"></b></a> <a href="search_product?@request.SetAndGetString("sort", "pd")"
                                        title="按价格从高到低" >价格<b class="descIcon"></b></a> <a href="search_product?@request.SetAndGetString("sort", "p")"
                                            title="按价格从低到高" >价格<b class="ascIcon"></b></a>
                                </ul>
                                <dl class="price-order">
                                    <dt>价格排序：</dt>
                                    <dd class="by-price">
                                        <div class="price-range" id="J_FilterPrice">
                                            <input class="text" type="text" maxlength="8" size="6" name="start_price" title="价格过滤最低价格">
                                            -
                                            <input class="text" type="text" value="" maxlength="8" size="6" name="end_price"
                                                title="价格过滤最高价格">
                                            <p class="sub-menu">
                                                <input type="submit" title="按价格过滤" value="确定" class="btnSearch" id="J-pricebtn" />
                                                <input type="button" title="按价格过滤" value="取消" class="btnSearch" id="J-pricecal" />
                                            </p>
                                        </div>
                                    </dd>
                                </dl>
                            }
                        </div>
                        </form>
                        <div class="ui-quick-page-changer">
                            @{
                                var totalPages = int.Parse(ViewData["totalPages"].ToString());
                                var currentIndex = int.Parse(ViewData["currentIndex"].ToString());
                                <p class="ui-page-s">
                                    <b class="ui-page-s-len">@ViewData["currentIndex"]/@ViewData["totalPages"]</b>
                                    @if (currentIndex == 1)
                                    {
                                        <b class="ui-page-s-prev" title="上一页">&lt;</b>
                                    }
                                    else
                                    {
                                        <a href="search_product?@request.SetAndGetString("currentIndex", (@currentIndex - 1).ToString())" class="ui-page-s-next" title="上一页">
                                            &lt;</a>
                                    }
                                    @if (currentIndex == totalPages)
                                    {
                                        <b class="ui-page-s-prev" title="下一页">&gt;</b>
                                    }
                                    else
                                    {
                                        <a href="search_product?@request.SetAndGetString("currentIndex", (@currentIndex + 1).ToString())"
                                    class="ui-page-s-next" title="下一页">&gt;</a>
                                    }
                                </p>
                            }
                        </div>
                    </div>
                </div>
                <!--商品列表形式开始 grid-->
                <div id="J-listContainer" class="list-content grid" data-spm="1008.1000032.1000012">
                    <h2 class="offScreen">
                        商品列表</h2>
                    <ul class="product-list">
                        @if (Model != null)
                        {
                            var imgpath = Enter.Config.ImgPathConfig.productListServerPath;
                            foreach (var entity in Model)
                            {
                            <li class="product">
                                <div class="productInfo">
                                    <div class="product-img">
                                        <a href="/Detail/item?id=@entity.GID">
                                            <img class="pro-viewimg" src="@imgpath@entity.ImgUrl"/></a>
                                    </div>
                                    <p class="product-price">
                                        <strong class="tmall-price">@entity.SalePRICE.ToString("f2")</strong>
                                    </p>
                                    <h3 class="product-title">
                                        <a href="/Detail/item?id=@entity.GID">@entity.Title </a>
                                    </h3>
                                    <div class="product-sum">
                                        <b>月销量:<strong class="proHigh">@entity.MonthSaleCount</strong></b> | <a href="#;">总评论:@entity.CommentCount</a>
                                    </div>
                                </div>
                            </li>
                            }
                        }
                    </ul>
                </div>
                <!--商品列表页尾翻页开始-->
                <div id="J_ListBottom" class="list-bottom" style="clear: both;">
                    <div class="pagination ui-pagination mb20">
                        <div class="page-bottom">
                            <div class="ui-page">
                                <div class="ui-page-wrap">
                                    @{
                                        //var totalPages = int.Parse(ViewData["totalPages"].ToString());
                                        //var currentIndex = int.Parse(ViewData["currentIndex"].ToString());

                                        var yu = @currentIndex / 6;
                                        if (totalPages > 1)
                                        {
                                            Enter.Common.RequestHelper request1 = new Enter.Common.RequestHelper(Request.QueryString);
                                        
                                        <b class="ui-page-num">
                                            @if (currentIndex == 1)
                                            {
                                                <b class="ui-page-prev">&lt;&lt;</b>
                                                <b class="ui-page-prev">&lt;</b>
                                            }
                                            else
                                            { 
                                                <a href="search_product?@request.SetAndGetString("currentIndex", "1")">&lt;&lt;</a>
                                                <a href="search_product?@request.SetAndGetString("currentIndex", (@currentIndex - 1).ToString())">
                                                    &lt;</a>
                                            }
                                            @for (var i = 6 * yu + 1; i <= totalPages; i++)
                                            {
                                                if (currentIndex == i)
                                                {
                                                <b class="ui-page-cur">@i</b>
                                                }
                                                else
                                                { 
                                                <a href="search_product?@request.SetAndGetString("currentIndex", i.ToString())">@i</a>
                                                }
                                                if (i >= 6 * (yu + 1))
                                                {
                                                <b class="ui-page-break">...</b> 
                                                    break;
                                                }
                                            }
                                            @if (currentIndex == totalPages)
                                            {
                                                <b class="ui-page-next">&gt;</b>
                                                <b class="ui-page-next">&gt;&gt;</b>
                                            }
                                            else
                                            { 
                                                <a class="ui-page-next" href="search_product?@request.SetAndGetString("currentIndex", (@currentIndex + 1).ToString())">
                                                    &gt;</a> 
                                                <a class="ui-page-next" href="search_product?@request.SetAndGetString("currentIndex", (@totalPages).ToString())">
                                                    &gt;&gt;</a> 
                                            }
                                        </b>   
                                        <b class="ui-page-skip">
                                            <form id="filterPageForm" name="filterPageForm" method="get" action="">
                                            共 @ViewData["totalPages"].ToString() 页，到第
                                            <input type="text" name="jumpto" class="ui-page-skipTo" size="3" value="@currentIndex">
                                            页
                                            <button type="submit" class="ui-btn-s">
                                                确定</button>
                                            </form>
                                        </b>
                                        } 
                                    }
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
